﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Hive.Bot.Tasks;
using Hive.Core;

namespace Hive.Bot.Behaviours
{
    public class AttackHiveBehavior: IBehaviour
    {
        int limit = 0;
        public AttackHiveBehavior()
        {

        }
        public AttackHiveBehavior(int limit)
        {
            this.limit = limit;
        }

        public List<ITask> GenerateTasks()
        {
            var maxAnts = 0;
            if (limit > 0)
                maxAnts = limit;
            else
                maxAnts = Env.MyAnts.Count;

            var result = new List<ITask>();

            if (Env.EnemyHills.Any())
            {
                var targets = Env.EnemyHills.Where(eh => Env.Map.GetDistance(Env.MyHills.First(), eh) < int.MaxValue);
                foreach(var target in targets)
                {
                    for (int i = 0; i < maxAnts / targets.Count(); i++)
                    {
                        result.Add(new AttackHiveTask(target));
                    }
                }
            }
            return result;
        }
    }
}
